Providing the Application With Printing Options
QuickDraw GX sends theGXDefaultPrinter
message when an application creates a job object so that your driver can create new view devices that represent the specific features provided by your printing device. These features include color information. For raster printing devices, the features also include resolution variations; for vector printing devices, the features include pen information. You can override this message to create view devices for your driver. You attach these view devices to the job object, and the application can then access them to determine specific device settings.The ImageWriter II printer driver provides various printing resolutions and allows the application to print either in black and white or in color. The driver overrides the
GXDefaultPrinter
message to add two high resolution (144 dpi) view devices for use by applications. This message override, theSD_DefaultPrinter
function, is shown in Listing 3-5. TheGXDefaultPrinter
message is described on page 4-50 in the chapter "Printing Messages."Listing 3-5 Modifying the default printer object
OSErr SD_DefaultPrinter(gxPrinter thePrinter) { OSErr anErr; gxViewDevice vd; /* add the standard view devices first */ anErr = Forward_GXDefaultPrinter(thePrinter); nrequire(anErr, DefaultPrinter); /* add a 144 b/w view device */ vd = NewDeviceResolutionViewDevice(); { gxSetColor theColors[2]; gxSetColor *pColor; gxColorSet theSet; pColor = &theColors[0]; pColor->rgb.red = 0xFFFF; pColor->rgb.green = 0xFFFF; pColor->rgb.blue = 0xFFFF; pColor++; pColor->rgb.red = 0x0000; pColor->rgb.green = 0x0000; pColor->rgb.blue = 0x0000; theSet = GXNewColorSet(gxRgbSpace, 2, theColors); SetViewDeviceColorSet(vd, theSet); GXDisposeColorSet(theSet); } anErr = GXAddPrinterViewDevice(thePrinter, vd); nrequire(anErr, FailedAddBWViewDevice); /* add a 144 color view device with 8 colors */ if (PrinterHasColorRibbon()) { gxSetColor theColors[8]; gxSetColor *pColor; gxColorSet theSet; short idx; vd = NewDeviceResolutionViewDevice(); pColor = &theColors[0]; for (idx = 0; idx < 8; ++idx) { /* default the color to black */ pColor->rgb.red = 0x0000; pColor->rgb.green = 0x0000; pColor->rgb.blue = 0x0000; /* then fill in the RGB components */ if (idx & 0x04) pColor->rgb.red = 0xFFFF; if (idx & 0x02) pColor->rgb.green = 0xFFFF; if (idx & 0x01) pColor->rgb.blue = 0xFFFF; ++pColor; /* move onto the next color */ } theSet = GXNewColorSet(gxRgbSpace, 8, theColors); SetViewDeviceColorSet(vd, theSet); GXDisposeColorSet(theSet); anErr = GXAddPrinterViewDevice(thePrinter, vd); nrequire(anErr, FailedAddColorViewDevice); } return(noErr); /* exception handling */ FailedAddColorViewDevice: FailedAddBWViewDevice: GXDisposeViewDevice(vd); GXDefaultPrinter: return(anErr); }TheSD_DefaultPrinter
function first forwards theGXDefaultPrinter
message so that the standard view devices can be added, then adds two of its own: a 144 dpi 1-bit view device and a 144 dpi 8-color view device. This function uses afor
loop to assign color values that correspond to the eight basic RGB colors. These values are shown in Table 3-5.The
SD_DefaultPrinter
function calls two local functions, the code for which is found in the QuickDraw GX sample code:
- The
NewDeviceResolutionViewDevice
function creates a view device object and sets up its mapping for 144 dpi.- The
PrinterHasColorRibbon
function returnstrue
if the desktop printer information says that the printing device has a color ribbon installed on it.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help